import request from '@/config/axios'

// 发票整合 VO
export interface InvoiceIntegrationVO {
  id: string // 主键id
  integrationId: string // 整合编号
  orderTotalPric: number // 总价格
  orderNum: number // 订单数量
  status: number // 状态
  invoiceStatus: string // 发票审核状态
  payStatus: string // 打款审核状态
}

// 发票整合 API
export const InvoiceIntegrationApi = {
  // 查询发票整合分页
  getInvoiceIntegrationPage: async (params: any) => {
    return await request.get({ url: `/erp/invoice-integration/page`, params })
  },

  // 查询发票整合详情
  getInvoiceIntegration: async (id: number) => {
    return await request.get({ url: `/erp/invoice-integration/get?id=` + id })
  },
  // 发起工作流
  sendInvoiceIntegration: async (id: number) => {
    return await request.get({ url: `/erp/invoice-integration/sendInvoiceIntegration?id=` + id })
  },

  // 新增发票整合
  createInvoiceIntegration: async (data: InvoiceIntegrationVO) => {
    return await request.post({ url: `/erp/invoice-integration/create`, data })
  },

  // 修改发票整合
  updateInvoiceIntegration: async (data: InvoiceIntegrationVO) => {
    return await request.put({ url: `/erp/invoice-integration/update`, data })
  },

  // 删除发票整合
  deleteInvoiceIntegration: async (id: number) => {
    return await request.delete({ url: `/erp/invoice-integration/delete?id=` + id })
  },

  // 导出发票整合 Excel
  exportInvoiceIntegration: async (params) => {
    return await request.download({ url: `/erp/invoice-integration/export-excel`, params })
  },

  // 根据发票审核单编号 修改发票审核单状态
    updateInvoiceCheckListStatusByCheckInvoiceId: async (checkInvoiceId: string, invoiceStatus: string, taskId: string, approvalOpinion: string) => {
      return await request.put({ url: `/erp/invoice-integration/update-status-by-check-invoice-id?checkInvoiceId=${checkInvoiceId}&invoiceStatus=${invoiceStatus}&taskId=${taskId}&approvalOpinion=${approvalOpinion}` })
    },
    // 根据发票审核单编号 修改打款审核状态
    updateInvoiceCheckListPayStatusByCheckInvoiceId: async (checkInvoiceId: string, PayStatus: string, taskId: string, approvalOpinion: string) => {
      return await request.put({ url: `/erp/invoice-integration/update-pay-status-by-check-invoice-id?checkInvoiceId=${checkInvoiceId}&payStatus=${PayStatus}&taskId=${taskId}&approvalOpinion=${approvalOpinion}` })
    },
}
